// pages/classActiveList/classActiveList.js
const host=getApp().host;
Page({

  /**
   * 页面的初始数据
   */
  data: {
    arr:[],
    pageSize:10
  },


  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
    
  },

  /**初始化 */
  onLoad(){
    this.initList();
  },

  /**初始化列表 */
  initList(){
    wx.request({
      url: host+'/client/moralClassify/list?page=0&pageSize='+this.data.pageSize+'&classify='+wx.getStorageSync('userInfo').classify,
      success:res=>{
        let list=res.data.data.list;
        list.forEach(item=>{
          item.date=this.formatDate(item);
        })
        this.setData({
          arr:list
        })
      }
    })
  },

  formatDate(row) {
    let date = new Date(row.date);
    let month =
          date.getMonth() + 1 < 10
                ? "0" + (date.getMonth() + 1)
                : date.getMonth() + 1;
    let day =
          date.getDate() < 10
                ? "0" + date.getDate()
                : date.getDate();
    let hours =
          date.getHours() < 10
                ? "0" + date.getHours()
                : date.getHours();
    let minutes =
          date.getMinutes() < 10
                ? "0" + date.getMinutes()
                : date.getMinutes();
    return (
          date.getFullYear() +
          "-" +
          month +
          "-" +
          day +
          " " +
          hours +
          ":" +
          minutes
    )
  }
})